import { View } from "../../../../mvc/core/View";
import { DeployPanelItem } from "../../equipment/deploy/DeployPanelItem";
import { Language } from "../../../../../extend/language/Language";
import { SMountWash } from "../../../../../Message/Game/SMountWash";
import { ExpAddEffect } from "../../effect/ExpAddEffect";
import { ExpAddEffectInfo } from "../../../resource/info/ExpAddEffectInfo";
import { AttriAddEffect } from "../../effect/AttriAddEffect";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { MsgManager } from "../../../manager/MsgManager";
import { FlowerBg } from "../../common/FlowerBg";
import { ObjCreate } from "../../common/ObjCreate";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { ItemData } from "../../../resource/info/ItemData";
import { MountFosterAttrView } from "../mount/MountFosterAttrView";
import { LongProgressBar } from "../../player/LongProgressBar";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { TilePanel } from "../../equipment/TilePanel";
import { MountWashMaterialCellRenderer } from "../cell/MountWashMaterialCellRenderer";
import { EquipmentModuleConst } from "../../equipment/data/EquipmentModuleConst";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GameConst } from "../../../../component/gconst/GameConst";
import { DataEvent } from "../../../events/DataEvent";
import { ShopItemInfo } from "../../../resource/info/ShopItemInfo";
import { ColorConfig } from "../../../resource/ColorConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
import { Cache } from "../../../cache/Cache";
import { CalcUtil } from "../../common/util/CalcUtil";
import { ItemExInfo } from "../../../resource/info/ItemExInfo";
import { CareerUtil } from "../../common/util/CareerUtil";
import { EProp } from "../../../../../Message/Public/EProp";
import { ItemConfig } from "../../../resource/ItemConfig";
import { ItemInfo } from "../../../resource/info/ItemInfo";
import { EBind } from "../../../../../Message/Public/EBind";
import { ShopType } from "../../../resource/info/ShopType";
import { MaterialItemData } from "../../equipment/MaterialItemData";
import { SPlayerItem } from "../../../../../Message/Public/SPlayerItem";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { LockInfoData } from "../../lock/LockInfoData";
import { ELockStatus } from "../../../../../Message/Game/ELockStatus";
import { Log } from "../../../../../com/gengine/debug/Log";
import { PopupManager } from "../../../manager/PopupManager";
import { TodayNotTipUtil } from "../../../../common/TodayNotTipUtil";
import { TodayNoTipsConst } from "../../../../component/gconst/TodayNoTipsConst";
import { MountMutiWashPannel } from "./MountMutiWashPannel";
import { MountForsterReplacePanel } from "../mount/MountForsterReplacePanel";
import { PulseSharedObject } from "../../player/PulseSharedObject";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { ShopConfig } from "../../../resource/ShopConfig";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { _mountIData } from "../../../../../this/_mountIData";
import { _materials } from "../../../../../this/_materials";
import { Vector } from "../../../../../__AS3__/vec/Vector";
type int = number;
//class MountFosterPanel
    
    export  class MountFosterPanel extends View
    {
        constructor()
        {
            this.allItem = new Vector.<DeployPanelItem>();
            this.posData = [{"x": 115, "y": 31, "label": Language.getString(70045), "noBoarder": false}, {"x": 214, "y": 31, "label": Language.getString(70046), "noBoarder": true}];
            this._materialPanelData = [];
            this._materialArr = [];
            this._materials = new Array<any>();
            this._rangeBmArr = [];
            super();
            this.initView();
            this.addEventListeners();
            return;
        }

        public updateForsterTotalValue(arg1: SMountWash): void
        {
            if (arg1 && this._mountIData) 
            {
                if (arg1.addValue > 0) 
                {
                    this.addGrowthEffect(arg1.addValue);
                }
                this._prograssBar.setValue(this._mountIData.itemExInfo.m_was_best, this._maxValue * 3);
            }
            return;
        }

        /* internal  */playValueAddEffect(arg1: int): void
        {
            var loc1=localToGlobal(new Object /* flash.geom.Point */(180, 235));
            var loc2=new ExpAddEffect(new ExpAddEffectInfo(loc1.x, loc1.y, loc1.x, loc1.y, arg1, 1));
            loc2.playEffect();
            return;
        }

        public addGrowthEffect(arg1: int, arg2: Boolean=false): void
        {
            var loc1=new Object /* flash.geom.Point */(200, 235);
            var loc2=localToGlobal(new Object /* flash.geom.Point */(160, 200));
            AttriAddEffect.attriAdd(arg1, loc2.x, loc2.y, arg2);
            return;
        }

        public clear(): void
        {
            this.allItem[1].itemData = null;
            this.allItem[0].itemData = null;
            this._currentAttrView.clear();
            this._replaceAttrView.clear();
            this._prograssBar.setValue(0, 0);
            this._fightValueTx.text = "";
            this._raise.bitmapData = null;
            if (this._mutiWashPannel) 
            {
                this._mutiWashPannel.dispose();
                this._mutiWashPannel = null;
            }
            return;
        }

        /* internal  */addEventListeners(): void
        {
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddedToStage);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
            this._btnWash.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClick);
            this._btnMutiWash.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClick);
            this._btnReplace.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClick);
            return;
        }

        public updateForsterFightValue(arg1: int): void
        {
            if (!MountUtil.instance.isMountEquiped(this._mountIData)) 
            {
                this._fightValueTx.text = "";
                return;
            }
            if (arg1 > 0) 
            {
                this._raise.bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeRaise);
                this._fightValueTx.htmlText = "<font color=\'#00ff00\'>" + Language.getString(44524) + Language.getString(71111) + "： " + arg1 + "</font>";
                EffectManager.glowFilterReg(this._raise, [FilterConst.guideTipsFilter], 0.6, 10, 5, 3);
            }
            else if (arg1 < 0) 
            {
                this._raise.bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeDecline);
                this._fightValueTx.htmlText = "<font color=\'#ff0000\'>" + Language.getString(44524) + Language.getString(30245) + "： " + arg1 + "</font>";
                EffectManager.glowFilterReg(this._raise, [FilterConst.guideTipsFilter], 0.6, 10, 5, 3);
            }
            else 
            {
                this._raise.bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeSame);
                this._fightValueTx.htmlText = "<font color=\'#f0ea3f\'>" + Language.getString(44524) + Language.getString(36216) + "： " + arg1 + "</font>";
            }
            this._fightValueTx.filters = [FilterConst.glowFilter];
            return;
        }

        protected onBtnWash(): void
        {
            if (this._mountIData) 
            {
                if (this.isAttrBetter == true) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(71552));
                    return;
                }
                if (this.isNeedAlert && this.isCombatDif) 
                {
                    this.popuReplacePannel();
                }
                else 
                {
                    this.goWash();
                }
            }
            return;
        }

        /* internal  */initView(): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=null;
            this._spBg = new FlowerBg(367, 340);
            addChild(this._spBg);
            this._stBmMountBigWashBg = ObjCreate.createBitmap("", 1, 1, this._spBg);
            var loc1=new GImageBitmap("equipment_recast_recast.png", 166, 33);
            this._spBg.addChild(loc1);
            var loc2=0;
            while (loc2 < this.posData.length) 
            {
                loc4 = this.posData[loc2];
                (loc5 = new DeployPanelItem(loc2, loc4.noBoarder, false, "")).posIndex = loc2;
                loc5.x = loc4["x"];
                loc5.y = loc4["y"];
                loc5.label = loc4["label"];
                this._spBg.addChild(loc5);
                this.allItem.push(loc5);
                ++loc2;
            }
            this.allItem[0].item.toolTipType = ItemData.ToolTipType_Mounts;
            this._currentAttrView = new MountFosterAttrView(false);
            this._currentAttrView.move(10, 90);
            addChild(this._currentAttrView);
            this._replaceAttrView = new MountFosterAttrView(true);
            this._replaceAttrView.move(176, 90);
            addChild(this._replaceAttrView);
            this._fightValueTx = ObjCreate.createGTextField("", 220, 110, 110, 20, this);
            this._raise = ObjCreate.createBitmap("", 322, 112, this);
            this._fightValueTx.visible = false;
            this._prograssBar = new LongProgressBar();
            this._prograssBar.x = 45;
            this._prograssBar.y = 225;
            this._prograssBar.progressBarClass = ImagesConst.EnergyBar;
            this._prograssBar.setBgSize(280, 16);
            this._prograssBar.setValue(0, 100);
            addChild(this._prograssBar);
            this._stWarmBm = ObjCreate.createBitmap("", 20, 252, this);
            this._btnContainer = new Object /* flash.display.Sprite */();
            this._btnContainer.x = 60;
            this._btnContainer.y = 280;
            addChild(this._btnContainer);
            this._btnWash = ObjCreate.createGButton(Language.getString(71509), 0, 0, 70, 28, this._btnContainer, "ButtonRedMini");
            this._btnWash.toolTipData = Language.getString(71526);
            this._btnMutiWash = ObjCreate.createGButton(Language.getString(71557), 90, 0, 70, 28, this._btnContainer, "ButtonRedMini");
            this._btnReplace = ObjCreate.createGButton(Language.getString(70142), 180, 0, 70, 28, this._btnContainer, "ButtonRedMini");
            this._btnReplace.toolTipData = Language.getString(71527);
            ObjCreate.createLabel(Language.getString(70023), 261, 315, 100, 20, flash.text.TextFormatAlign.LEFT, this._spBg, true, 15859633);
            loc3 = ResouceConst.getScaleBitmap(ImagesConst.DisabledBg);
            loc3.x = 301;
            loc3.y = 315;
            loc3.setSize(65, 20);
            this._spBg.addChild(loc3);
            ObjCreate.createBitmap(ImagesConst.Tongqian_small, 343, 317, this._spBg);
            this._txCost = ObjCreate.createTextField("0", 303, 315, 60, 20, this._spBg);
            this.useBindMaterial = ObjCreate.createCheckBox(Language.getString(60323), 4, 315, 150, 28, this);
            this.useBindMaterial.textField.filters = [FilterConst.glowFilter];
            this.useBindMaterial.selected = true;
            this.useBindMaterial.addEventListener(flash.events.Event.CHANGE, this.onUseBindChange);
            this._spMaterial = new FlowerBg(169, 339);
            this._spMaterial.x = 369;
            addChild(this._spMaterial);
            ObjCreate.createBg(0, 1, 120, 26, this._spMaterial, ImagesConst.TileBg);
            this._stBmMountWashMaterial = ObjCreate.createBitmap("", 5, 5, this._spMaterial);
            this._autoBuy = ObjCreate.createCheckBox(Language.getString(70024), 6, 30, 100, 20, this._spMaterial, "GRadioButton");
            this._buyDirect = ObjCreate.createCheckBox(Language.getString(70025), 6, 50, 90, 20, this._spMaterial, "GRadioButton");
            this._buyDirect.selected = true;
            this._materialList = new TilePanel();
            this._materialList.x = 8;
            this._materialList.y = 72;
            this._materialList.setSize(160, 264);
            this._materialList.rowHeight = 66;
            this._materialList.columnWidth = 158;
            this._materialList.verticalGap = 4;
            this._materialList.horizontalGap = 2;
            this._materialList.setStyle("cellRenderer", MountWashMaterialCellRenderer);
            this._materialList.addEventListener(EquipmentModuleConst.Event_DoBuyEvent, this.buyMaterialHandler);
            this._spMaterial.addChild(this._materialList);
            this._pageSelec = ObjCreate.createPageSelecter(23, 310, this._spMaterial, PageSelecter.CompleteMode);
            this._spDesc = new FlowerBg(536, 58);
            this._spDesc.x = 0;
            this._spDesc.y = 342;
            addChild(this._spDesc);
            this._txDesc = ObjCreate.createTextField("", 7, 9, 500, 65, this._spDesc);
            this._txDesc.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._txDesc.multiline = true;
            this._txDesc.wordWrap = true;
            this._txDesc.mouseWheelEnabled = false;
            this._txDesc.htmlText = Language.getString(71510);
            this._contentPane = new GScrollPane();
            this._contentPane.styleName = "GScrollPane";
            this._contentPane.verticalScrollPolicy = ScrollPolicy.ON;
            this._contentPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._contentPane.width = 520;
            this._contentPane.height = 54;
            this._contentPane.x = 3;
            this._contentPane.y = 3;
            this._contentPane.source = this._txDesc;
            this._spDesc.addChild(this._contentPane);
            LoaderHelp.addResCallBack(ResFileConst.mount, this.onLoadBmResource);
            this._cost = GameConst.MountWashCostCoin;
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stBmMountBigWashBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountBigWashBg);
            this._stBmMountWashMaterial.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountWashMaterial);
            this._stWarmBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.fosterWarm);
            return;
        }

        protected buyMaterialHandler(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=0;
            var loc4=null;
            var loc5=null;
            if (this._buyDirect.selected) 
            {
                loc1 = arg1.data.shopItemInfo as ShopItemInfo;
                loc2 = arg1.data.amount as int;
                loc3 = loc1.tshopSell.offer > 0 ? loc1.tshopSell.offer * loc2 : loc1.tshopSell.price * loc2;
                loc4 = ColorConfig.instance.getItemColor(loc1.itemInfo.item.color);
                loc5 = "        " + Language.getStringByParam(61023, HTMLUtil.addColor(loc2 + "", "#FF0000"), HTMLUtil.addColor(loc1.itemInfo.item.name, loc4.color), HTMLUtil.addColor(loc3 + GameDefConfig.instance.getEPrictUnitName(loc1.unit), "#FFEA00"));
                Alert.extendObj = arg1.data;
                Alert.show(loc5, Language.getString(69900), Alert.OK | Alert.CANCEL, null, this.onBuyAlertHanlder);
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallBuyItem, arg1.data));
            }
            return;
        }

        /* internal  */onBuyAlertHanlder(arg1: int, arg2: Object): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallBuyItem, arg2));
            }
            return;
        }

        protected onUseBindChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateDatas();
            return;
        }

        protected onAddedToStage(arg1: Object /* flash.events.Event */): void
        {
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.updateMaterial);
            return;
        }

        protected onRemovedFromStage(arg1: Object /* flash.events.Event */): void
        {
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.updateMaterial);
            return;
        }

        public updateInfo(arg1: ItemData): void
        {
            this._mountIData = arg1;
            if (this._mountIData) 
            {
                this._updateFlag = false;
                this.allItem[0].itemData = this._mountIData;
                this.updateDatas();
                if (MountUtil.instance.isMountEquiped(this._mountIData)) 
                {
                    this._fightValueTx.visible = true;
                    this._raise.visible = true;
                    if (this._mountIData.itemExInfo.m_was_new != "") 
                    {
                        this.updateForsterFightValue(this._mountIData.itemExInfo.m_was_combat_dif);
                    }
                    else 
                    {
                        this.updateForsterFightValue(0);
                    }
                }
                else 
                {
                    this._fightValueTx.visible = false;
                    this._raise.visible = false;
                }
            }
            else 
            {
                this.clear();
            }
            return;
        }

        /* internal  */updateDatas(): void
        {
            var loc1=false;
            var loc2=0;
            if (this._mountIData) 
            {
                loc1 = Cache.instance.role.isPhysicalCareer;
                this._valueArray = MountUtil.getFosterAttrArray(this._mountIData, loc1, false);
                this._replaceValueArray = MountUtil.getFosterAttrArray(this._mountIData, loc1, true);
                this._addvalueArray = CalcUtil.getMutiArray(this._valueArray, this._replaceValueArray);
                this._maxValue = Cache.instance.pack.mountsPackCache.getFosterMaxValue(this._mountIData);
                this._currentAttrView.updateValue(this._valueArray, this._maxValue);
                this._replaceAttrView.updateValue(this._replaceValueArray, this._maxValue);
                this._replaceAttrView.updateAddValue(this._addvalueArray);
                loc2 = Cache.instance.role.money.coin + Cache.instance.role.money.coinBind;
                this._costEnough = this._cost <= loc2;
                this.allItem[1].itemData = this.getMaterialItemdata();
                this.allItem[1].enabled = this._materialEnough;
                this._prograssBar.setValue(this._mountIData.itemExInfo.m_was_best, this._maxValue * 3);
            }
            else 
            {
                this.clear();
            }
            this.updateInfos();
            return;
        }

        /* internal  */updateInfos(): void
        {
            var loc1=null;
            if (this._mountIData) 
            {
                loc1 = this._costEnough ? "#FFFF00" : "#FF0000";
                this._txCost.htmlText = HTMLUtil.addColor(this._cost + "", loc1);
                this.mutiWashPannel.updateMoney();
            }
            else 
            {
                this._txCost.htmlText = HTMLUtil.addColor("0", "#FFFF00");
            }
            return;
        }

        /* internal  */getHeightestMount(): ItemData
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            if (this._mountIData) 
            {
                loc1 = new ItemData(this._mountIData.itemCode);
                loc2 = new ItemExInfo();
                loc2 = this._mountIData.itemExInfo.duplicate();
                loc3 = Cache.instance.role.careerBasic;
                if (CareerUtil.isPhysicalCareer(loc3)) 
                {
                    loc2.m_was_p = this._maxValue;
                    loc2.m_was_a = this._maxValue;
                    loc2.m_was_h = this._maxValue;
                    loc2.m_was_b = 0;
                    loc2.m_was_s = 0;
                }
                else if (CareerUtil.isMagicCareer(loc3)) 
                {
                    loc2.m_was_p = 0;
                    loc2.m_was_a = 0;
                    loc2.m_was_h = this._maxValue;
                    loc2.m_was_b = this._maxValue;
                    loc2.m_was_s = this._maxValue;
                }
                else 
                {
                    loc2.m_was_p = 0;
                    loc2.m_was_a = 0;
                    loc2.m_was_h = 0;
                    loc2.m_was_b = 0;
                    loc2.m_was_s = 0;
                }
                loc1.itemExInfo = loc2;
                return loc1;
            }
            return null;
        }

        /* internal  */getMaterialItemdata(): ItemData
        {
            var loc1=0;
            var loc3=null;
            var loc5=0;
            var loc6=0;
            var loc7=0;
            var loc8=null;
            var loc9=null;
            this._materialArr = [];
            this._materials = [];
            var loc2=Cache.instance.pack.backPackCache.getPropItems();
            var loc4=loc2.length;
            loc1 = 0;
            while (loc1 < loc4) 
            {
                loc3 = loc2[loc1] as ItemData;
                if (loc3.itemInfo.item.type == EProp._EPropMountRefreshGrow) 
                {
                    this._materialArr.push(loc3);
                }
                ++loc1;
            }
            if (this.useBindMaterial.selected) 
            {
                this._materialArr.sortOn("bind", Array.DESCENDING);
            }
            else 
            {
                this._materialArr.sortOn("bind");
            }
            var loc10=0;
            var loc11=this._materialArr;
            for(loc3 of loc11) 
            {
                this._materials.push(loc3.uid);
            }
            this._materialEnough = false;
            if ((loc6 = this._materialArr.length) > 0) 
            {
                loc7 = 0;
                while (loc7 < loc6) 
                {
                    if ((loc5 = loc5 + (this._materialArr[loc7] as ItemData).itemAmount) >= this._materialNum) 
                    {
                        this._materialEnough = true;
                    }
                    ++loc7;
                }
            }
            if (loc6 > 0) 
            {
                return this._materialArr[0] as ItemData;
            }
            loc8 = ItemConfig.instance.getPropsByType(EProp._EPropMountRefreshGrow);
            loc1 = 0;
            while (loc1 < loc8.length) 
            {
                if ((loc9 = new ItemData((loc8[loc1] as ItemInfo).item.code)).itemInfo.item.bind == EBind._EBindNo) 
                {
                    return loc9;
                }
                ++loc1;
            }
            return null;
        }

        public updateMaterial(arg1: Object=null): void
        {
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc8=null;
            var loc9=null;
            var loc10=0;
            var loc11=null;
            var loc12=null;
            var loc1=Cache.instance;
            var loc2=[];
            var loc3=new Map<any, any> /* flash.utils.Dictionary */();
            loc4 = loc1.equipment.getMaterialData(this._opertionType);
            loc5 = loc1.equipment.getMaterialBuyData(this._opertionType, ShopType.PetForge);
            loc6 = 0;
            while (loc6 < loc4.length) 
            {
                if ((loc9 = loc4[loc6]["data"] as ItemData).itemInfo.item.bind != EBind._EBindYes) 
                {
                    loc10 = loc9.itemInfo.item.code;
                }
                else 
                {
                    loc10 = loc9.itemInfo.item.codeUnbind;
                }
                if (loc10 != 0) 
                {
                    if (loc3[loc10]) 
                    {
                        (loc3[loc10] as MaterialItemData).itemData.itemAmount = (loc3[loc10] as MaterialItemData).itemData.itemAmount + loc9.itemAmount;
                    }
                    else 
                    {
                        (loc8 = new MaterialItemData()).itemData = new ItemData(loc10);
                        loc8.itemData.itemAmount = loc9.itemAmount;
                        loc8.itemData.uid = loc9.uid;
                        loc3[loc10] = loc8;
                    }
                }
                ++loc6;
            }
            loc6 = 0;
            while (loc6 < loc5.length) 
            {
                loc12 = loc5[loc6]["data"];
                if (loc3[loc12.itemInfo.item.code]) 
                {
                    (loc8 = loc3[loc12.itemInfo.item.code] as MaterialItemData).isInShop = true;
                    loc8.shopItem = loc12;
                }
                else 
                {
                    (loc8 = new MaterialItemData()).isInShop = true;
                    loc8.shopItem = loc12;
                    (loc11 = new SPlayerItem()).itemCode = loc12.itemInfo.item.code;
                    loc8.itemData = new ItemData(loc11);
                    loc3[loc11.itemCode] = loc8;
                }
                ++loc6;
            }
            var loc13=0;
            var loc14=loc3;
            for(loc8 of loc14) 
            {
                loc2.push(loc8);
            }
            loc2.sortOn("code");
            this._materialPanelData = loc2;
            this.updateShowedMaterial();
            return;
        }

        /* internal  */updateShowedMaterial(): void
        {
            this._pageSelec.maxPage = Math.ceil(this._materialPanelData.length / this.pagesize);
            var loc1=(this._pageSelec.currentPage - 1) * this.pagesize;
            var loc2=this._pageSelec.currentPage * this.pagesize > this._materialPanelData.length ? this._materialPanelData.length : this._pageSelec.currentPage * this.pagesize;
            var loc3=this._materialPanelData.slice(loc1, loc2);
            this._materialList.dataProvider = new DataProvider(loc3);
            return;
        }

        protected onBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (LockInfoData.lockStatus.value() == ELockStatus._ELockStatusLocked) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.LockSetUnLockOpen));
                return;
            }
            if (!MountUtil.instance.isCanFoster(this._mountIData)) 
            {
                return;
            }
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._btnWash:
                {
                    Log.system("调接口值：" + Cache.instance.pack.mountsPackCache.markGetMountForsterGetFightValueFlag.toString(), "快速点击值：" + this._updateFlag.toString());
                    if (this.isAttrBetter == true) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(71552));
                        return;
                    }
                    if (Cache.instance.pack.mountsPackCache.markGetMountForsterGetFightValueFlag || this._updateFlag) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(71553));
                        return;
                    }
                    this.onBtnWash();
                    break;
                }
                case this._btnReplace:
                {
                    this.onBtnReplace();
                    break;
                }
                case this._btnMutiWash:
                {
                    this.onBtnMutiWash();
                    break;
                }
            }
            return;
        }

        /* internal  */onBtnMutiWash(): void
        {
            if (this.isAttrBetter == true) 
            {
                MsgManager.showRollTipsMsg(Language.getString(71552));
                return;
            }
            if (Cache.instance.pack.mountsPackCache.markGetMountForsterGetFightValueFlag || this._updateFlag) 
            {
                MsgManager.showRollTipsMsg(Language.getString(71553));
                return;
            }
            if (this.isNeedAlert && this.isCombatDif) 
            {
                this.popuReplacePannel(true);
            }
            else 
            {
                this.mutiWash();
            }
            return;
        }

        /* internal  */mutiWash(): void
        {
            var loc2=null;
            var loc1=this.cheackCanWash(true, false);
            if (loc1 == this.WASH_CHECK_OK || loc1 == this.WASH_CHECK_LACK_COIN) 
            {
                PopupManager.addPopUp(this.mutiWashPannel, "window", true);
                loc2 = {"autoBuy": this._autoBuy.selected, "mountIData": _mountIData, "useBindMaterial": this.useBindMaterial.selected, "materials": _materials};
                this.mutiWashPannel.mutiWash(loc2);
            }
            return;
        }

        /* internal  */onBtnReplace(): void
        {
            var replaceRequest: Function;

            var loc1;
            if (this._mountIData) 
            {
                replaceRequest = (): void
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MountGoWashReplace, _mountIData));
                    return;
                }
                if (this._mountIData.itemExInfo.m_was_new == null || this._mountIData.itemExInfo.m_was_new == "") 
                {
                    MsgManager.showRollTipsMsg(Language.getString(71545));
                    return;
                }
                TodayNotTipUtil.toDayNotTip(TodayNoTipsConst.MountFosterReplaceNotTip, replaceRequest, Language.getString(71528), null, Alert.OK | Alert.CANCEL);
            }
            return;
        }

        public get mutiWashPannel(): MountMutiWashPannel
        {
            if (this._mutiWashPannel == null) 
            {
                this._mutiWashPannel = new MountMutiWashPannel();
            }
            return this._mutiWashPannel;
        }

        public get replacePanel(): MountForsterReplacePanel
        {
            if (!this._replacePanel) 
            {
                this._replacePanel = new MountForsterReplacePanel();
                this._replacePanel.addEventListener(EventName.MountForsterReplaceOkClick, this.onMountForsterReplaceOkClick);
                this._replacePanel.addEventListener(EventName.MountForsterReplaceCancerClick, this.onMountForsterReplaceCancerClick);
            }
            return this._replacePanel;
        }

        /* internal  */get isNeedAlert(): Boolean
        {
            var loc1=!PulseSharedObject.isTodayNotTips("mountForsterReplacePanel");
            return loc1;
        }

        /* internal  */get isCombatDif(): Boolean
        {
            return this._mountIData.itemExInfo.m_was_combat_dif > 0;
        }

        protected onMountForsterReplaceOkClick(arg1: DataEvent): void
        {
            if (!MountUtil.instance.isCanFoster(this._mountIData)) 
            {
                return;
            }
            if (this._mountIData.itemExInfo.m_was_new == null || this._mountIData.itemExInfo.m_was_new == "") 
            {
                MsgManager.showRollTipsMsg(Language.getString(71545));
                return;
            }
            this._updateFlag = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MountGoWashReplace, this._mountIData));
            return;
        }

        protected onMountForsterReplaceCancerClick(arg1: DataEvent): void
        {
            var loc1=arg1.data;
            if (loc1.isMutiWash != true) 
            {
                this.goWash();
            }
            else 
            {
                this.mutiWash();
            }
            return;
        }

        /* internal  */goWash(): void
        {
            var closeAlert: Function;

            var loc1;
            if (this.cheackCanWash() == 0) 
            {
                closeAlert = (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        _updateFlag = true;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MountGoWash, {"posType": _mountIData.posType, "mountUid": _mountIData.uid, "count": 1, "materials": _materials, "autoBuy": _autoBuy.selected}));
                    }
                    return;
                }
                if (this.checkChangeToBind()) 
                {
                    Alert.show(Language.getString(70050), null, Alert.OK | Alert.CANCEL, null, closeAlert);
                }
                else 
                {
                    closeAlert(Alert.OK);
                }
            }
            return;
        }

        /* internal  */popuReplacePannel(arg1: Boolean=false): void
        {
            PopupManager.addPopUp(this.replacePanel, "window", true);
            this.replacePanel.setWashType(arg1);
            var loc1=this.localToGlobal(new Object /* flash.geom.Point */(110, 282));
            this.replacePanel.x = loc1.x - this.replacePanel.btnOK.x;
            this.replacePanel.y = loc1.y - this.replacePanel.btnOK.y;
            return;
        }

        /* internal  */checkChangeToBind(): Boolean
        {
            var loc1=0;
            var loc2=null;
            if (this._mountIData && ItemsUtil.isBind(this._mountIData)) 
            {
                return false;
            }
            if (this._mountIData) 
            {
                var loc3=0;
                var loc4=this._materialArr;
                for(loc2 of loc4) 
                {
                    if (loc1 >= this._materialNum) 
                    {
                        return false;
                    }
                    loc1 = loc1 + loc2.itemAmount;
                    if (!ItemsUtil.isBind(loc2)) 
                    {
                        continue;
                    }
                    return true;
                }
            }
            return false;
        }

        /* internal  */cheackCanWash(arg1: Boolean=false, arg2: Boolean=true): int
        {
            var loc2=null;
            var loc3=0;
            if (!this._materialEnough) 
            {
                loc3 = (loc2 = ShopConfig.instance.getShopItemInfoByCode(14108300, 1702)).tshopSell.offer > 0 ? loc2.tshopSell.offer : loc2.tshopSell.price;
                if (!this._autoBuy.selected || this._autoBuy.selected && Cache.instance.login.loginGame.money.gold < loc3) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54190));
                    return this.WASH_CHECK_LACK_ITEM;
                }
            }
            var loc1=Cache.instance.role.money.coin + Cache.instance.role.money.coinBind;
            if (this._cost > loc1) 
            {
                if (arg2) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(70060));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallAutoBuyCoin, this._cost - loc1));
                }
                return this.WASH_CHECK_LACK_COIN;
            }
            if (this.allItem[1].enabled == false) 
            {
                if (this.allItem[1].itemData) 
                {
                    if (this._autoBuy.selected) 
                    {
                        return this.WASH_CHECK_OK;
                    }
                    MsgManager.showRollTipsMsg(Language.getStringByParam(60226, this.allItem[1].itemData.name));
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(60235));
                }
                return this.WASH_CHECK_LACK_ITEM;
            }
            return this.WASH_CHECK_OK;
        }

        /* internal  */get isAttrBetter(): Boolean
        {
            var loc1=0;
            var loc2=0;
            var loc3=0;
            while (loc3 < this._replaceValueArray.length) 
            {
                loc1 = int(this._replaceValueArray[loc3]);
                if (loc1 == this._maxValue) 
                {
                    ++loc2;
                }
                ++loc3;
            }
            if (loc2 == 3 || this._mountIData && this._mountIData.itemExInfo.m_was_best == this._maxValue * 3) 
            {
                return true;
            }
            return false;
        }

        /* internal  */get isFosterNew(): Boolean
        {
            var loc1=0;
            var loc2=0;
            while (loc2 < this._addvalueArray.length) 
            {
                loc1 = this._addvalueArray[loc2];
                if (loc1 > 0) 
                {
                    return true;
                }
                ++loc2;
            }
            return false;
        }

        /* internal */ /* const */WASH_CHECK_OK: int=0;

        /* internal */ /* const */WASH_CHECK_LACK_ITEM: int=1;

        /* internal */ /* const */WASH_CHECK_LACK_COIN: int=2;

        /* internal */ /* const */GrowLowestPercent: number=0.125;

        /* internal */ /* const */GrowHightestPercent: number=0.5;

        /* internal */ /* var */_valueArray: Array<any>;

        /* internal */ /* var */_replaceValueArray: Array<any>;

        /* internal */ /* var */_btnContainer: Object /* flash.display.Sprite */;

        /* internal */ /* var */_maxValue: int;

        /* internal */ /* var */_prograssBar: LongProgressBar;

        /* internal */ /* var */_stWarmBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_fightValueTx: GTextFiled;

        /* internal */ /* var */_raise: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_spBg: FlowerBg;

        /* internal */ /* var */_btnWash: GButton;

        /* internal */ /* var */_btnMutiWash: GButton;

        /* internal */ /* var */_btnReplace: GButton;

        /* internal */ /* var */_bmCostBg: ScaleBitmap;

        /* internal */ /* var */_addvalueArray: Array<any>;

        /* internal */ /* var */_bmTongQian: ScaleBitmap;

        /* internal */ /* var */_txCost: Object /* flash.text.TextField */;

        /* internal */ /* var */_spGrowBar: FlowerBg;

        /* internal */ /* var */_currentAttrView: MountFosterAttrView;

        /* internal */ /* var */_replaceAttrView: MountFosterAttrView;

        /* internal */ /* var */_mutiWashPannel: MountMutiWashPannel;

        /* internal */ /* var */_spMaterial: FlowerBg;

        /* internal */ /* var */_spDesc: FlowerBg;

        /* internal */ /* var */pagesize: int=4;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_updateFlag: Boolean;

        /* internal */ /* var */_buyDirect: GCheckBox;

        /* internal */ /* var */_autoBuy: GCheckBox;

        /* internal */ /* var */_txDesc: Object /* flash.text.TextField */;

        /* internal */ /* var */useBindMaterial: GCheckBox;

        /* internal */ /* var */_materialList: TilePanel;

        /* internal */ /* var */_replacePanel: MountForsterReplacePanel;

        /* internal */ /* var */_mountIData: ItemData;

        /* internal */ /* var */allItem: Vector.<DeployPanelItem>;

        /* internal */ /* var */posData: Array<any>;

        /* internal */ /* var */_opertionType: int=18;

        /* internal */ /* var */_materialPanelData: Array<any>;

        /* internal */ /* var */_costEnough: Boolean;

        /* internal */ /* var */_pageSelec: PageSelecter;

        /* internal */ /* var */_materialEnough: Boolean;

        /* internal */ /* var */_cost: int;

        /* internal */ /* var */_mountGrade: int;

        /* internal */ /* var */_materialNum: int=1;

        /* internal */ /* var */_materialArr: Array<any>;

        /* internal */ /* var */_materials: Array<any>;

        /* internal */ /* var */_rangeBmArr: Array<any>;

        /* internal */ /* var */_contentPane: GScrollPane;

        /* internal */ /* var */_stBmMountBigWashBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmMountWashMaterial: Object /* flash.display.Bitmap */;
    }
